<script>

import axios from "axios"  // 组间引用 axios
import querystring from "querystring"  // POST方式，,需要安装 npm install --save querystring

import{getSZ} from '../api/index.js'


export default {
    name: "Network",

    data() {
        return {
            result30:null, //初始化结果为null
            result60:null
        }
    }
    ,
    methods: {
        getSZDate(code) { //30 00开头

            console.log("点击了//30 00开头")

            getSZ(code)
                .then((res) => {

                    // 处理成功情况
                    let results = res.data.split("~");
                    // console.log(results)
                    let name = results[1]
                    let jiage = results[3]
                    let zhangfu = results[32]
                    let str = name + " " + zhangfu + " " + jiage
                    this.result30=str
                    return str
               
                }).finally(function () {



                })

        },
        getSHDate(code) {  //60开头
            const url = "http://qt.gtimg.cn/q=sh" + code
            axios.get(url)
                .then((res) => {

                    // 处理成功情况
                    let results = res.data.split("~");
                    // console.log(results)
                    let name = results[1]
                    let jiage = results[3]
                    let zhangfu = results[32]
                    let str = name + " " + zhangfu + " " + jiage
                    this.result60=str
                    return results
                
                }).finally(function () {

                })

        },

        startUi() { //循环任务
            setInterval(() => {
                this.getSHDate('601162')
                this.getSZDate('300827')
            }, 5000)
        }

    }
    , beforeCreate() { //创建之间

    },
    created() { //创建后


    }, beforeMount() {//挂载前

    }, mounted() {//挂在显示后

        // this.startUi()

    }, beforeUpdate() {//


    }, updated() {

    }, beforeDestroy() {

    }, default() {

    }
}

</script>




<!-- 000002  -->
<!-- 300827 上能电器 -->


<template>

    <div style="margin-top: 10px;margin-left: 10px;">
        <!-- <p v-on:click="getSZDate('300827')" style="color: brown;">Network</p>
        <p v-on:click="getSHDate('601162')" style="color: brown;">Network</p> -->
    <el-button type="primary"  v-on:click="getSZDate('300827')">3000</el-button>

    <el-button type="primary"  v-on:click="getSHDate('000002')">6000</el-button> 

    </div>
    
    <div style="display: flex;flex-direction: column;">
        <span id="result" style="color:#919191;">{{result30}}</span>
        <span id="result1">{{result60}}</span>
    </div>

</template>


<style scoped></style>
